import { createRouter, createWebHistory } from 'vue-router'
import { routes } from './routes'
import NProgress from '@/utils/nprogress' // 引入NProgress

const router = createRouter({
    history: createWebHistory(),
    routes,
})

router.beforeEach((to, from, next) => {
    NProgress.start() // 开始进度条
    if (to.meta.title) {
        document.title = `${to.meta.title} - MES系统`
    }
    next()
})

router.afterEach(() => {
    NProgress.done() // 结束进度条
})

export default router
